package com.AI.AIDemo.Demos.Web.Controller.AIController;

import com.AI.AIDemo.Demos.RnnRandomForest;
import com.AI.AIDemo.Demos.Web.CentralNervousSystem.CentralNervous;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.dromara.easyai.nerveCenter.ModelParameter;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * @author 大力王
 * {@code @Date:2025/4/27-27-14:06}
 * 开始了
 */
@RestController
@Tag(name = "AI测试")
@CacheConfig(cacheNames = "AI")
@Slf4j
public class AITestController {
    @Resource
    private CentralNervous centralnervous;

    @RequestMapping(value="/test", method = RequestMethod.GET)
    @Operation(summary = "获取AI信息测试",description = "AI测试用")
    public ModelParameter test(@Parameter (name = "world") String world) throws Exception{
        log.info("AI测试:"+centralnervous.modelParameterTest()+"+++名字:"+world);
        log.info("AI测试:"+centralnervous.TestSensoryNerveList().get(1).toString()+"+++名字:"+world);
        return centralnervous.modelParameterTest();
    }

    @RequestMapping(value="/test2", method = RequestMethod.GET)
    @Operation(summary = "获取AI信息测试2",description = "AI测试用2")
    public int test2() throws Exception{
        RnnRandomForest model = new RnnRandomForest(10, 3, 10);
        double[] testInput = new double[10];
        Arrays.fill(testInput, 0.000000115);
        return model.predict(testInput);
    }
}
